home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part2 / 12486 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.4 KB

  1. Path: news.compuserve.com!newsmaster
  2. From: 100435.736@compuserve.com (David A. Mair)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: How to Call Windows API from DOS app.
  5. Date: Mon, 01 Apr 1996 09:55:21 GMT
  6. Organization: CompuServe Incorporated
  7. Message-ID: <4jo5pa$srl@dub-news-svc-3.compuserve.com>
  8. References: <3159E0E6.1363@central.gvrd.bc.ca>
  9. NNTP-Posting-Host: dd35-167.compuserve.com
  10. X-Newsreader: Forte Free Agent 1.0.82
  11.  
  12. Jay Toor <JTOOR@central.gvrd.bc.ca> wrote:
  13.  
  14. >Anyone have any ideas how I can call functions like,
  15.  
  16. >GetPrivateProfileString and WritePrivateProfileString from
  17. >a DOS C program?
  18.  
  19. >Is this possible?
  20.  
  21. Jay,
  22.  
  23. I've always cooked my own, they're not all that complicated.  I
  24. optimise them by making the assumption that .INI files are small (16
  25. bit Windows has a limit of 64kB on them).  I get the file size,
  26. allocate that amount of memory and read the entire file into memory
  27. with one operation (much faster than string reads).  I then build a
  28. string containing the section name surrounded by square brackets and
  29. search the memory block for it.  I then search for the next open
  30. square brackets at the start of a line and I have the star and end
  31. addresses of the section.  I search these limits for the item name
  32. followed by an equals sign and return everything after the equals to
  33. the end of the line into the user supplied buffer and free the .INI
  34. file memory block.
  35.  
  36. Regards
  37. David.
  38.  
  39.